package com.sl.au.repository;

import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import com.sl.au.entity.Attachment;

public interface AttachmentRepository extends JpaRepository<Attachment, String> {
	
	@Query("select a from Attachment a where a.parentId=?1 and "
			+ "a.groupId=?2  order by a.groupId ,a.createTime desc ")
	List<Attachment> findByParentIdAndGroupId(String parentId, String groupId);

	@Query("select a from Attachment a where a.parentId=?1 "
			+ "order by a.groupId ,a.createTime desc ")
	List<Attachment> findByParentId(String parentId);

	Attachment findBySavedFileName(String savedFileName);
	
	void deleteByParentIdAndGroupId(String parentId,String groupId);
}
